package com.info.zhiduoduo.core.dto.zhaoshang;

import com.info.zhiduoduo.common.constants.Constants;
import com.info.zhiduoduo.repository.entity.crowdsource.CrowdsourceTradeRecordItem;
import com.info.zhiduoduo.repository.entity.order.TradeRecord;
import com.info.zhiduoduo.repository.entity.partner.PartnerWithdraw;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.math.RoundingMode;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class ZhaoShangAgentPayFormBean {

	private int paymentMerchant;
	//业务参考号
	private String tradeNo;
	//金额
	private BigDecimal amount;
	//银行卡号
	private String acctno;
	//户名
	private String acctname;
	//交易描述
	private String describe;

	public static ZhaoShangAgentPayFormBean of(CrowdsourceTradeRecordItem recordItem, Integer paymentMerchantId, Integer workType) {
		return new ZhaoShangAgentPayFormBean()
				.setPaymentMerchant(paymentMerchantId)
				.setAcctname(recordItem.getAcctname())
				.setAcctno(recordItem.getAcctno())
				.setAmount(recordItem.getTradeamount().setScale(2, RoundingMode.DOWN))
				.setTradeNo(recordItem.getTradeNo())
				.setDescribe(Constants.WORK_TYPE_1 == workType ? "智众包支付" : "智零工支付");
	}

	public static ZhaoShangAgentPayFormBean of(TradeRecord tradeRecord) {
		return new ZhaoShangAgentPayFormBean()
				.setPaymentMerchant(tradeRecord.getMerchantid())
				.setAcctname(tradeRecord.getAcctname())
				.setAcctno(tradeRecord.getAcctno())
				.setAmount(tradeRecord.getTradeamount().setScale(2, RoundingMode.DOWN))
				.setTradeNo(tradeRecord.getTradeno())
				.setDescribe(" 支付");
	}

	public static ZhaoShangAgentPayFormBean of(PartnerWithdraw withdraw, int paymentMerchant) {
		return new ZhaoShangAgentPayFormBean()
				.setPaymentMerchant(paymentMerchant)
				.setAcctname(withdraw.getAcctname())
				.setAcctno(withdraw.getAcctno())
				.setAmount(withdraw.getAmount().setScale(2, RoundingMode.DOWN))
				.setTradeNo(withdraw.getWdno())
				.setDescribe("代付费用");
	}
}
